<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const Event = (function () {
            let clientList = [],
                listen,
                trigger,
                remove;

            listen = function (key, fn) {
                if (!clientList[key]) {
                    clientList[key] = [];
                }
                clientList[key].push(fn);
            }

            trigger = function () {
                let key = Array.prototype.shift.call(arguments),
                    fns = clientList[key];

                if (!fns || fns.length === 0) {
                    return false;
                }

                for (let i = 0, fn; fn = fns[i++];) {
                    fn.apply(this, arguments);
                }
            }

            remove = function (key, fn) {
                let fns = clientList[key];
                if (!fns) {
                    return false
                }
                if (!fn) {
                    fns && (fns.length = 0)
                } else {
                    for (let i = fns.length - 1; i >= 0; i--) {
                        if (fns[i] = fn) {
                            fns.splice(i, 1);
                        }
                    }
                }
            }

            return {
                listen,
                trigger,
                remove,
            }
        })()

        console.log(Event.listen);

        Event.listen('squareMeter88', function (price) {
            console.log('价格= ' + price);
        });
        Event.trigger('squareMeter88', 2000000);
    </script>
</body>

</html>